<!DOCTYPE html	PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" xmlns:s="http://sduept.security.el/func"
	template="/template/template_dialog.xhtml">
	<ui:define name="head">
		<link href="/css/primefaces/menubase.css" rel="stylesheet" type="text/css" />
		<title>设置互查项</title>
		<style type="text/css">
			legend {
				width:150px;
				font-size:18px;
				margin:0px;
				font-weight:bd;
			}
			.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default {
			    background: #fff;
			    font-weight: bold;
			    color: #555;
			}
			.ui-autocomplete .ui-autocomplete-dropdown {
			    position: absolute;
			    height: 100%;
			    width: 17px;
			    right: -2px;
			    background: #3c8dbc !important;
			}
		</style>
		<script>
			var userDialogIndex;
			function openUserChooseDialog() {
				//打开页面
				userDialogIndex = layer.open({
					type : 2,
					maxmin : false,
					area : [ '420px', '500px' ],
					fixed : false, //不固定
					title : '人员选择器',
					content : '/ui/common/org_selector_user_single_layer.xhtml'
				});
			}
			function dialogReturn(index, data) {
				var params = [];
				data = eval("(" + data + ")");
				if (index == userDialogIndex) {
					params.push({
						name : 'className',
						value : data.className
					}, {
						name : 'userJson',
						value : data.data
					});
					onUserDialogReturn(params);
				}
			}
			/*关闭该弹窗并返回数据*/
			function closeAndSave(data) {
				//将对象转为JSON字符串
				data = JSON.stringify(data);
				var index = parent.layer.getFrameIndex(window.name);
				/* var data = document.getElementById("form1:inspectOtherItemData").value; */
				if (parent.dialogReturn) {
					parent.dialogReturn(index, data);
				}
				parent.layer.close(index);
			}
		</script>
	</ui:define>
 	
	<ui:define name="content">
		<!-- <h:form id="form1">
			<p:growl id="msgs" showDetail="true" />
			<h:inputHidden id="inspectOtherItemData" value="#{setInspectionOtherItemController.inspectOtherItemData}" />
			<p:toolbar>
				<f:facet name="left">
					<p:commandButton value="确定" 
						actionListener="#{setInspectionOtherItemController.closeAndReturn()}" />
				</f:facet>
			</p:toolbar>
			<p:panelGrid cellpadding="5" style="width:100%;">
				<p:row>
	            	<p:column>
	            		<p:outputLabel value="派出分子公司："></p:outputLabel>
	            	</p:column>
	            	<p:column>
						<p:selectOneMenu value="#{setInspectionOtherItemController.selectedScopeId}">
							<f:selectItem itemLabel=""/>
							<f:selectItems value="#{setInspectionOtherItemController.allMaintenanceScopes}" var="scope" itemLabel="#{scope.name}" itemValue="#{scope.id}"/>
							<p:ajax event="itemSelect" />
						</p:selectOneMenu>
					</p:column>
	            	<p:column>
	            		<p:outputLabel style="color:blue" value="联系人（可不选)："></p:outputLabel>
	            	</p:column>
	            	<p:column>
	            		<h:inputText disabled="true" id="inspectionScopePersonnel" value="#{setInspectionOtherItemController.inspectionScopePersonnel}" required="true"/>
						<p:commandButton value="选择" icon="ui-icon-extlink" style="font-size:12px"
							onclick="openUserChooseDialog()"/>
						<p:remoteCommand name="onUserDialogReturn" update=":form1:inspectionScopePersonnel" 
							actionListener="#{setInspectionOtherItemController.onUserDialogReturn}" />
	            	</p:column>
	            </p:row>
			</p:panelGrid>
			<p:fieldset legend="被检单位" style="margin:10px">
				<p:tree id="unitTree" widgetVar="unitTree" dynamic="true" 
					animate="true" var="node" style="border:0;height:300px;overflow-y:scroll;padding-left:20px;border-top:1px solid #eee"
					value="#{setInspectionOtherItemController.root}"
					selectionMode="checkbox" selection="#{setInspectionOtherItemController.selectedNodes}" >
					<p:ajax event="select" listener="#{inspectionStationSelectorController.onStationNodeSelect}" />
					<p:ajax event="unselect" listener="#{inspectionStationSelectorController.onStationNodeUnSelect}" />
					<p:treeNode type="root">
						<h:outputText value="#{node}" />
					</p:treeNode>
					<p:treeNode type="scope">
						<h:outputText value="#{node}" />
					</p:treeNode>
					<p:treeNode type="unit">
						<h:outputText value="#{node}" />
					</p:treeNode>
				</p:tree>
			</p:fieldset>
		</h:form> -->
				<h:form id="form1">
		<div class="ui-g">
			<div class="ui-g-12">
					<p:toolbar>
						<f:facet name="left">
							<p:commandButton value="确定" 
								actionListener="#{setInspectionOtherItemController.closeAndReturn()}" />
						</f:facet>
					</p:toolbar>
			</div>
		</div>
		<div class="ui-g">
			<div class="ui-g-6">
					<p:fieldset legend="派出分子公司" style="margin:10px">
						<p:dataTable var="item" value="#{setInspectionOtherItemController.models}" rowKey="#{item.inspectionScope}" emptyMessage="无记录"
							 selection="#{setInspectionOtherItemController.selectedModels}" scrollable="true" scrollHeight="300">
							<p:column selectionMode="multiple" style="text-align:center;width:10%"/>
							<p:column headerText="名称" style="text-align:center">
						        <h:outputText value="#{item.inspectionScope}" />
						    </p:column>
						    <p:column headerText="联系人" style="text-align:center">
						        <p:autoComplete id="inspectionScopePersonnel" value="#{item.inspectionScopePersonnel}" scrollHeight="200"
									completeMethod="#{setInspectionOtherItemController.completeInspectionScopePersonnels}" dropdown="true" inputStyle="width:100%">
									<f:attribute name="model" value="#{item}"></f:attribute>
									<p:ajax event="itemSelect" listener="#{setInspectionOtherItemController.onInspectionScopePersonnelSelect(item)}" update="@form"></p:ajax>
									<p:ajax event="keyup"></p:ajax>
								</p:autoComplete>
						    </p:column>
						</p:dataTable>
					</p:fieldset>
			</div>
			<div class="ui-g-6">
					<p:fieldset legend="被检单位" style="margin:10px">
						<p:tree id="unitTree" widgetVar="unitTree" dynamic="true" 
							animate="true" var="node" style="border:0;height:330px;overflow-y:scroll;padding-left:20px;border-top:1px solid #eee"
							value="#{setInspectionOtherItemController.root}"
							selectionMode="checkbox" selection="#{setInspectionOtherItemController.selectedNodes}" >
							<p:treeNode type="root">
								<h:outputText value="#{node}" />
							</p:treeNode>
							<p:treeNode type="scope">
								<h:outputText value="#{node}" />
							</p:treeNode>
							<p:treeNode type="unit">
								<h:outputText value="#{node}" />
							</p:treeNode>
						</p:tree>
					</p:fieldset>
			</div>
		</div>
		</h:form>
	</ui:define>
</ui:composition>


